/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.stat.model.data;

/**
 * We expect specific models to subclass.
 * @author stewari1
 */
public abstract class ModelData {

    /** Field description */
    protected String requestDataLabel;

    /** Field description */
    protected String responseDataLabel;

    /**
     * indicates if the data is request data or not. Note that a data cannot be
     * both a request and response.
     */
    protected boolean[] requestIndices;

    /**
     * indicates if the data is response data or not
     */
    protected boolean[] responseIndices;

    /** Field description */
    protected DataAttribute[] dataAttributes;

    /** Field description */
    private final ModelDataSummary modelDataSummary;

    /**
     * Constructs ...
     */
    protected ModelData() {
        this.modelDataSummary = new ModelDataSummary(this);
    }

    public ModelDataSummary getModelDataSummary() {
        return modelDataSummary;
    }

    /**
     * package-private access: Used by Record using object composition
     * @return
     */
    boolean[] getRequestIndices() {
        return requestIndices;
    }

    /**
     * package-private access: Used by Record using object composition
     * @return
     */
    boolean[] getResponseIndices() {
        return responseIndices;
    }

    public void setAsRequestData(int index) {

        this.requestIndices[index]  = true;
        this.responseIndices[index] = false;
    }

    public void setAsResponseData(int index) {

        this.responseIndices[index] = true;
        this.requestIndices[index]  = false;
    }

    public String getRequestDataLabel() {
        return requestDataLabel;
    }

    public String getResponseDataLabel() {
        return responseDataLabel;
    }

    public DataAttribute[] getDataAttributes() {
        return dataAttributes;
    }

    public abstract Record[] getRecords();
}
